<!-- 
说明：新建
作者：刘永盛 
日期：2018-6-23 21:33:4 
版本：1.0.0
-->
<template>
  <div>
    <mk-button :type="0"
            icon="el-icon-plus"
            @click="show">新建</mk-button>
    <cmResourceFolder-form v-if="visible"
                   @close="close"
                   :rstype="rstype"
                   :is-add="true"
                   title="新建"
                   btn-name="保存" />
  </div>
</template>
<script>
  import CmResourceFolderForm from './form'
  export default {
    name: 'add-button',
    components: {
      CmResourceFolderForm
    },
    props: {
      rstype: String
    },
    data () {
      return {
        visible: false
      }
    },
    methods: {
      show () {
        this.visible = true
      },
      /**
       * 关闭对话框时触发
       * 根据弹框是否需要重载页面而反馈到列表
       */
      close (reload) {
        this.visible = false
        if (reload === true) {
          this.$emit('reload')
        }
      }
    }
  }
</script>